package com.binance.eureka.config;

import javax.annotation.Resource;

import org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;

import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.cluster.PeerEurekaNodes;
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
import com.netflix.eureka.resources.ServerCodecs;

@Configuration
public class BnbPeerEurekaNodesConfig extends EurekaServerAutoConfiguration {

    @Resource
    protected Environment env;
    
    @Bean
    @Primary
    public PeerEurekaNodes peerEurekaNodes(PeerAwareInstanceRegistry registry, ServerCodecs serverCodecs,
            ApplicationInfoManager applicationInfoManager, EurekaServerConfig eurekaServerConfig,
            EurekaClientConfig eurekaClientConfig) {
        return new BnbPeerEurekaNodes(registry, eurekaServerConfig, eurekaClientConfig, serverCodecs,
                applicationInfoManager,env);
    }

}
